package com.hashmap;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class PokerDemo {
    public static void main(String[] args) {
        // 生成一副牌，每一张牌，都是一个对象poker

        List<PokerTrue> pokerTrueList = new ArrayList<>();
        pokerTrueList.add(new PokerTrue("大王",53));
        pokerTrueList.add(new PokerTrue("小王",52));
        String[] arrflow = {"♥️", "♠️️", "♣️️", "♦️️"};
        String[] arrpai = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K","A", "2"};
        int i = 0;
        for (String pai : arrpai) {
            for (String flow : arrflow) {
                pokerTrueList.add(new PokerTrue(flow + pai,i));
                i++;
            }
        }
        Collections.shuffle(pokerTrueList);
        List<PokerTrue> play1 = new ArrayList();
        List<PokerTrue> play2 = new ArrayList();
        List<PokerTrue> play3 = new ArrayList();
        List<PokerTrue> dipai = new ArrayList();

        for (int j = 0; j < pokerTrueList.size(); j++) {
            if (j >= 51) {
                dipai.add(pokerTrueList.get(j));
            } else if (j % 3 == 0) {
                play1.add(pokerTrueList.get(j));
            } else if (j % 3 == 1) {
                play2.add(pokerTrueList.get(j));
            } else if( j % 3 == 2){
                play3.add(pokerTrueList.get(j));
            }
        }
        sort(play1);
        sort(play2);
        sort(play3);
        System.out.println(play1);
        System.out.println(play2);
        System.out.println(play3);
        System.out.println(dipai);

    }


    /*
    给牌做排序
    */
         public static void sort(List<PokerTrue> pokerTrueList) {
             Collections.sort(pokerTrueList, new Comparator<PokerTrue>() {
                 @Override
                 public int compare(PokerTrue o1, PokerTrue o2) {
                     return  o1.getLevel() - o2.getLevel();
                 }
             });
         }

}
